//  封装post请求
const network = axios.create({
  baseURL: location.origin + "/app/",
})
network.interceptors.request.use((config) => {
  if (!config.headers) {
    config.headers = {}
  }
  config.headers["accessToken"] = sessionStorage.getItem("accessToken")
  return config
})

var networkPost = function (url, data = {}) {
  return new Promise((resolve, reject) => {
    network.post(url, data).then(
      (response) => {
        if (response.data.resultCode == "-9") {
          //token 过期
          showAlert("提示", "TOKEN过期,刷新页面", () => {
            console.log("------刷新页面----->")
            reload()
          })
          return
        }
        resolve(response.data)
      },
      (err) => {
        reject(err)
      }
    )
  })
}
